package com.stedu.mall.goodsservice;

import com.stedu.mall.common.bean.Goods;
import com.stedu.mall.common.bean.GoodsPic;
import com.stedu.mall.common.exception.MallException;
import com.stedu.mall.common.service.GoodsService;
import com.stedu.mall.goodsservice.mapper.GoodsMapper;
import com.stedu.mall.goodsservice.mapper.GoodsPicMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.math.BigDecimal;
import java.util.ArrayList;

@SpringBootTest
public class MyTest01 {
    @Autowired
    private GoodsPicMapper goodsPicMapper;
    @Autowired
    private GoodsMapper goodsMapper;
    @Autowired
    private GoodsService goodsService;

    @Test
    public void test11() throws MallException {
       Goods goods = new Goods(null, "111",
               "111", "111",
               new BigDecimal(0), new BigDecimal(0), new BigDecimal(0),
               "红", "1.1",
               1, 0, 0, 0F, 0,
               null,null);
       goodsService.insert(goods);
   }

    @Test
    public void test01(){
        goodsPicMapper.selectByGoodsId(4)
                .stream()
                .forEach(System.out::println);
    }

    @Test
    public void test02(){
        System.out.println(goodsPicMapper.delete(1000));
    }
    @Test
    public void test03(){
        ArrayList<GoodsPic> goodsPics = new ArrayList<>();
        goodsPics.add(new GoodsPic(null, "11111", 1000));
        goodsPics.add(new GoodsPic(null, "11122", 1000));
        goodsPics.add(new GoodsPic(null, "11133", 1000));
        goodsPics.add(new GoodsPic(null, "11144", 1000));
        System.out.println(goodsPicMapper.insert(goodsPics));
    }
    @Test
    public void test04(){
        System.out.println(goodsMapper.selectById(1));
    }
    @Test
    public void test05(){
        Goods goods = new Goods();
        goods.setName("手机");

        goodsMapper.selectByCondition(goods)
                .stream()
                .forEach(System.out::println);
    }
    @Test
    public void test06(){
        String path1 = "/goods/1dasd";
        String path2 = "/goods/1";
        String reg = "^\\/goods\\/.+";

        System.out.println(path2.matches(reg));
    }
}
